<?php

namespace App;

use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\Access\Authorizable;

class User extends Model implements AuthenticatableContract,
AuthorizableContract,
CanResetPasswordContract {
	use Authenticatable, Authorizable, CanResetPassword;

	/**
	 * The database table used by the model.
	 * 白名单
	 *
	 * @var string
	 */
	protected $table = 'users';

	/**
	 * The attributes that are mass assignable.
	 *
	 * @var array
	 */
	protected $fillable = [];

	/**
	 * The attributes excluded from the model's JSON form.
	 *
	 * @var array
	 */
	protected $hidden = ['password', 'remember_token'];

	//用户详情表, 1 对 1
	public function datail() {
		return $this->hasOne('App\user_datail', 'user_id');
	}

	//用户评论表, 1 对 n
	public function discuss() {
		return $this->hasMany('App\discuss', 'user_id');
	}

	//用户提问表, 1 对 n
	public function question() {
		return $this->hasMany('App\question', 'user_id');
	}

	// 用户文章表, 1 对 n
	public function article() {
		return $this->hasMany('App\article', 'user_id');
	}

	//用户收藏表, 1 对 n
	public function collection() {
		return $this->hasMany('App\collection', 'user_id');
	}

	//用户日志
	public function log() {
		return $this->hasMany('App\log', 'user_id');
	}
}
